package cn.suzhang.designpatterns.singleton;

/**
 * 懒汉式单例模式
 * 
 * @author suzhang
 *
 */
public class LazySingleton {
	public static LazySingleton instance;

	private LazySingleton() {
	}

	/**
	 * 调用时初始化，线程安全
	 * 
	 * @return
	 */
	synchronized public static LazySingleton getInstance() {

		if (instance == null) {
			instance = new LazySingleton();
		}
		return instance;
	}

}
